home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_09 / barbu2 / ctl.hpp < prev    next >
C/C++ Source or Header  |  1995-05-07  |  2KB  |  84 lines

  1. //////// AB CLASSGEN Sat Apr 29 04:23:36 1995 ////////
  2. // CTL, an abstract control
  3. //////////////////////////////////////////////////////
  4. #if !defined(CTL_HPP)
  5. #define CTL_HPP
  6. #if !defined(RC_INVOKED)    // no Windows RC compiler
  7. #include "SHOWDATA.HPP"
  8. #include "DESCRIPT.HPP"
  9. #include "MEMBLOCK.HPP"
  10.  
  11. class CTL {
  12. public:
  13.     CTL(const DESCRIPT& Desc, SHOWDATA * Guru)
  14.             : _desc(Desc), _guru(Guru) { _hDlg = 0; }
  15.     virtual ~CTL() {}
  16.  
  17.     // these values should be computed on ctor:
  18.     int duW() { return _duw; }
  19.     int duH() { return _duh; }
  20.  
  21.     virtual int addToDlg(int nFirstFreeId,
  22.                         MEMBLOCK *pTemplateSoFar,
  23.                         int duX, int duY) = 0;
  24.                     // returns # of dialog items added
  25.  
  26.     void initScreen(HWND hDlg){
  27.             _hDlg = hDlg;
  28.             dataToScreen();
  29.             }
  30.     virtual BOOL wm_command(int nId, int nCommand)
  31.                             { return FALSE; }
  32.     virtual BOOL isDataOk() { return TRUE; }
  33.     virtual void saveData() = 0;
  34.  
  35. typedef struct DLGITEMTag {
  36.     int   dtilX;
  37.     int   dtilY;
  38.     int   dtilCX;
  39.     int   dtilCY;
  40.     int   dtilID;
  41.     long  dtilStyle;
  42.     BYTE  dtilClass;
  43.     char  dtilText[1];
  44.     BYTE   dtilInfo;
  45.     } DLGITEM;
  46.  
  47. protected:
  48.     SHOWDATA* _guru;
  49.     const DESCRIPT _desc;
  50.     int _duh, _duw;
  51.     HWND _hDlg;
  52.  
  53.     static const DLGITEM _Text;
  54.     static const DLGITEM _Edit;
  55.     static const DLGITEM _Check;
  56.     static const DLGITEM _Combo;
  57.     static const DLGITEM _Push;
  58.  
  59.     virtual void dataToScreen() = 0;
  60.  
  61. private:
  62.     CTL();
  63.     CTL(const CTL&);
  64.     CTL& operator=(const CTL&);
  65. };
  66.  
  67. class CTLMAPPER {
  68. public:
  69.     virtual int duwText(const char szS[],
  70.             BOOL bForButton = FALSE) const = 0;
  71.     virtual int duhText() const = 0;
  72.     virtual int duhEdit() const = 0;
  73.     virtual int duhPush() const = 0;
  74.     virtual int duSquareBox() const = 0;
  75.     virtual int duwScreen() const = 0;
  76.     virtual int duhScreen() const = 0;
  77.     };
  78.  
  79. inline int max( int a, int b){ return a>b?a:b; }
  80. inline int min( int a, int b){ return a>b?b:a; }
  81.  
  82. #endif
  83. #endif
  84.